package gtkwire.listener.connector;

import gtkwire.*;
import gtkwire.widget.GtkWidget;
import gtkwire.listener.FilteringGTKMessageListener;
import gtkwire.listener.ButtonListener;

public class ButtonListenerFilter extends FilteringGTKMessageListener
{
	private ButtonListener l;

	public ButtonListenerFilter( ButtonListener l )
	{
		super( l );
		this.l = l;
		addFilteringWidgetType( GtkWidget.WT_GtkButton );
		addFilteringWidgetType( GtkWidget.WT_GtkToggleButton );
		addFilteringSignal( GTKWireSignal.CLICKED );
		addFilteringSignal( GTKWireSignal.PRESSED );
		addFilteringSignal( GTKWireSignal.RELEASED );
		setMatchMode( this.MUST_MATCH_ALL );
	}
	
	public void filteredMessage( GTKWireMessage msg )
	{
		if( GTKWireSignal.CLICKED.isMatch( msg )) l.buttonClicked( msg );
		if( GTKWireSignal.PRESSED.isMatch( msg )) l.buttonPressed( msg );
		if( GTKWireSignal.RELEASED.isMatch( msg )) l.buttonReleased( msg );
	}

}//end class